﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    
    private static List<ObjLoaiTour> lstLoaiTour;
    public string tin_header;
   
   
    protected void Page_Load(object sender, EventArgs e)
    {
        
        List<ObjGioHang> lstGioHang = new List<ObjGioHang>();
        if (Session["gio_hang"] != null)
        {
            lstGioHang = (List<ObjGioHang>)Session["gio_hang"];
            
            int tong_tien=0;
            int soluong = 0;
            foreach (ObjGioHang item in lstGioHang)
            {
                soluong+=item.So_luong;
                tong_tien += item.Gia * item.So_luong;
            }
            lb_so_luong_hang.Text = soluong.ToString();
            lb_so_tien.Text = String.Format("{0:0,0}", tong_tien)+Constants.LOAI_TIEN;
        }
        else
        {
            lb_so_luong_hang.Text = "0";
            lb_so_tien.Text = "0" + Constants.LOAI_TIEN;
        }

        Tin tin = new Tin();
        List<ObjTin> lst = tin.getTinType(Constants.TIN_HEADER);
        if (lst.Count > 0)
        {
            tin_header = lst[0].Tom_tat;
        }
       

    }
    protected void load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoaiTour loaiTour = new LoaiTour();
            lstLoaiTour = loaiTour.getDanhMucTourSearch();
            drop_danh_muc.DataSource = lstLoaiTour;
            drop_danh_muc.DataTextField = "ten_loai_tour";
            drop_danh_muc.DataValueField = "loai_tour_id";
            drop_danh_muc.DataBind();
        }
    }
    protected void btn_search_Click(object sender, EventArgs e)
    {
        Response.Redirect("/tour.aspx?text=" + txt_search.Text);
    }
    protected void btn_search_Click1(object sender, EventArgs e)
    {
        Utils utils = new Utils();
        List<WebControl> lstWebControl = new List<WebControl>();
        lstWebControl.Add(txtgiatu);
        lstWebControl.Add(txtgiaden);
        
        lb_messenger.Text = utils.checkDataType(lstWebControl);
        if (lb_messenger.Text == "")
        {
            int giatu = int.Parse(txtgiatu.Text);
            int giaden = int.Parse(txtgiaden.Text);
            int danhmuc = int.Parse(drop_danh_muc.SelectedValue.ToString());
            Response.Redirect("/tour.aspx?text1=" + danhmuc + "&giatu=" + giatu + "&giaden=" + giaden);
        }
    }
    
}
